<?php
/**
 * @version		$Id: controller.php 11299 2008-11-22 01:40:44Z ian $
 * @package		Joomla
 * @subpackage	Users
 * @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
 * @license		GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * See COPYRIGHT.php for copyright notices and details.
 */

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.controller');

/**
 * Users Component Controller
 *
 * @package		Joomla
 * @subpackage	Users
 * @since 1.5
 */
class MessreportsController extends JController
{
	/**
	 * Constructor
	 *
	 * @params	array	Controller configuration array
	 */
	function __construct($config = array())
	{
		parent::__construct($config);

		// Register Extra tasks//注册任务与方法的关联
		$this->registerTask( 'add'  , 	'display'  );
		$this->registerTask( 'edit'  , 	'display'  );
		$this->registerTask( 'apply', 	'save'  );
		//$this->registerTask( 'flogout', 'logout');
		//$this->registerTask( 'unblock', 'block' );
		$this->registerTask( 'enban', 'enban');
		
	}

	/**
	 * Displays a view
	 */
	function display( )
	{
		switch($this->getTask())
		{
			case 'add'     :
			{	JRequest::setVar( 'hidemainmenu', 1 );
				JRequest::setVar( 'layout', 'form'  );
				JRequest::setVar( 'view', 'messreport' );
				JRequest::setVar( 'edit', false );
			} break;
			case 'edit'    :
			{
				JRequest::setVar( 'hidemainmenu', 1 );
				JRequest::setVar( 'layout', 'form'  );
				JRequest::setVar( 'view', 'messreport' );
				JRequest::setVar( 'edit', true );
			} break;
		}

		parent::display();
	}

	/**
	 * Saves the record
	 */
	function save()
	{
		global $mainframe;

		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );

		$option = JRequest::getCmd( 'option');

		// Initialize some variables
		$db			= & JFactory::getDBO('shaishaidb');

		$post = JRequest::get('post');
		


		/*
	 	 * Lets save the JUser object
	 	 */
		$query = 'UPDATE illegal_report SET status = '.$post['statustype'].' where id = '.$post['id'];
		
		$db->setQuery( $query );			
		$db->loadResult();
		
		switch ( $this->getTask() )
		{
			case 'apply':
				$msg = JText::_( '状态设置成功 ' .$post['id']);
				$this->setRedirect( 'index.php?option=com_messreports&view=messreport&task=edit&cid[]='. $post['id'], $msg );
				break;

			case 'save':
			default:
				$msg = JText::_( '状态设置成功 '.$post['id'] );
				$this->setRedirect( 'index.php?option=com_messreports', $msg );
				break;
		}
	}

	/**
	 * Removes the record(s) from the database
	 */
	

	/**
	 * Cancels an edit operation
	 */
	function cancel( )
	{
		$this->setRedirect( 'index.php?option=com_messreports' );
	}

}
